package com.ruoyi.workLogs.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.workLogs.domain.WorkLogs;
import com.ruoyi.workLogs.service.IWorkLogsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 工单操作日志Controller
 * 
 * @author ruoyi
 * @date 2025-06-16
 */
@RestController
@RequestMapping("/ruoyi/workLogs")
public class WorkLogsController extends BaseController
{
    @Autowired
    private IWorkLogsService workLogsService;

    /**
     * 查询工单操作日志列表
     */
    @PreAuthorize("@ss.hasPermi('ruoyi:workLogs:list')")
    @GetMapping("/list")
    public TableDataInfo list(WorkLogs workLogs)
    {
        startPage();
        List<WorkLogs> list = workLogsService.selectWorkLogsList(workLogs);
        return getDataTable(list);
    }

    /**
     * 导出工单操作日志列表
     */
    @PreAuthorize("@ss.hasPermi('ruoyi:workLogs:export')")
    @Log(title = "工单操作日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WorkLogs workLogs)
    {
        List<WorkLogs> list = workLogsService.selectWorkLogsList(workLogs);
        ExcelUtil<WorkLogs> util = new ExcelUtil<WorkLogs>(WorkLogs.class);
        util.exportExcel(response, list, "工单操作日志数据");
    }

    /**
     * 获取工单操作日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('ruoyi:workLogs:query')")
    @GetMapping(value = "/{logId}")
    public AjaxResult getInfo(@PathVariable("logId") Long logId)
    {
        return success(workLogsService.selectWorkLogsByLogId(logId));
    }

    /**
     * 新增工单操作日志
     */
    @PreAuthorize("@ss.hasPermi('ruoyi:workLogs:add')")
    @Log(title = "工单操作日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WorkLogs workLogs)
    {
        return toAjax(workLogsService.insertWorkLogs(workLogs));
    }

    /**
     * 修改工单操作日志
     */
    @PreAuthorize("@ss.hasPermi('ruoyi:workLogs:edit')")
    @Log(title = "工单操作日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WorkLogs workLogs)
    {
        return toAjax(workLogsService.updateWorkLogs(workLogs));
    }

    /**
     * 删除工单操作日志
     */
    @PreAuthorize("@ss.hasPermi('ruoyi:workLogs:remove')")
    @Log(title = "工单操作日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{logIds}")
    public AjaxResult remove(@PathVariable Long[] logIds)
    {
        return toAjax(workLogsService.deleteWorkLogsByLogIds(logIds));
    }
}
